package demo.ybt;

import java.util.Arrays;

public class P1233 {
    public static void main(String[] args) {
        P1233 p1233= new P1233();
        p1233.res(4,new int[]{23, 71, 87 ,32 ,70, 93 ,80, 76});
    }
    public int res(int n, int[] t) {
        if (t == null) {
            return 0;
        }
        int[] s = new int[n];
        int max = 0;
        for (int i = 0; i < t.length; i++) {
           /* int minindex = 0;
            for (int j = 0; j < s.length; j++) {//n
                if (s[j] < s[minindex]) {
                    minindex = j;
                }
            }
            s[minindex] += t[i];
            max = Math.max(s[minindex], max);*/
            Arrays.sort(s); //n*lgn 从小到大
            s[0]+= t[i];
        }
        System.out.println(max);
        return max;
    }
}
